#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int numberOfArithmeticSlices(vector<int> &nums)
{
    int n = nums.size();
    vector<int> dp(n, 0);
    for (int i = 2; i < n; i++)
    {
        if (nums[i] - nums[i - 1] == nums[i - 1] - nums[i - 2])
        {
            dp[i] = dp[i - 1] + 1;
        }
    }
    return accumulate(dp.begin(), dp.end(), 0);
}

int main()
{
    vector<int> A{1, 2, 3, 4};
    cout << numberOfArithmeticSlices(A) << endl;
    return 0;
}